Page({
  data: {
    colors: ['红', '蓝', '绿', '黄'],
    color1: '红',
    color2: '蓝',
    resultText: '请选择两种颜色进行混合'
  },

  bindColorChange1: function(e) {
    this.setData({
      color1: this.data.colors[e.detail.value]
    });
  },

  bindColorChange2: function(e) {
    this.setData({
      color2: this.data.colors[e.detail.value]
    });
  },

  mixColors: function() {
    const color1 = this.data.color1;
    const color2 = this.data.color2;
    const resultColor = this.calculateMixedColor(color1, color2);
    this.setData({
      resultText: resultColor
    });
  },

  calculateMixedColor: function(color1, color2) {
    const colorMap = {
      '红+蓝': '紫',
      '红+绿': '棕',
      '红+黄': '橙',
      '蓝+绿': '青',
      '蓝+黄': '绿',
      '绿+黄': '橄榄绿'
    };

    const key = color1 + '+' + color2;
    return colorMap[key] || '未知颜色组合';
  }
});